var express = require('express');
var router = express.Router();
const connection = require("../db/sql");
const {getData} = require('../DAO/getData')
const {selectRole, deleteRole, addRole} = require('../services/role')
const {deleteData} = require("../DAO");
const modifyRole = require("../services/role/modify");
// 获取角色信息
router.get('/roles', async (req, res) => {
    console.log(req.user, '78546')
    await selectRole(req.query, res)
});

//删除角色
router.delete('/role/delete', async (req, res) => {
    // console.log(req.query.role_id,'啥都会欧艾斯')
    await deleteRole(req.query.role_id, res)
})
//修改角色权限
router.put('/role/update', (req, res) => {
    // console.log(77)
    modifyRole(req.body, res)
})
//添加角色
router.post('/role/add', (req, res) => {
    console.log(req.body, '收到货怕')
    // return 0
    addRole(req.body, res, req.user.role)
})


module.exports = router;
